package com.taxshare.operation.controller;

import com.taxshare.operation.service.ManagerService;
import com.taxshare.operation.service.ResourceService;
import com.taxshare.operation.view.dto.ResourceDTO;
import com.taxshare.response.beans.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ResourceController
 * @Description:
 * @author: luozhongyi
 * @date: 2021/1/29 14:12
 */
@RestController
@RequestMapping(value = "/resource")
@Api(tags = "资源管理")
public class ResourceController {

    @Autowired
    ResourceService resourceService;

    @Autowired
    ManagerService managerService;
    /**
     * 获取资源类型列表
     */
    @GetMapping("/code/resourceTypeCode")
    @ApiOperation(value = "获取资源类型列表", notes = "获取资源类型列表")
    public Response getResourceTypeCode() {
        return resourceService.getResourceTypeCode();
    }

    /**
     * 初始化左侧树
     */
    @GetMapping("/init/tree")
    @ApiOperation(value = "初始化左侧树", notes = "初始化左侧树")
    public Response initTree() {
        return resourceService.initTree();
    }

    /**
     * 查询明细信息
     */
    @GetMapping("/get/detail")
    @ApiOperation(value = "查询明细信息", notes = "查询明细信息")
    public Response getDetail(String resourceId) {
        return resourceService.getDetail(resourceId);
    }

    /**
     * 查询该菜单模块下的按钮页签集合
     */
    @GetMapping("/get/button")
    @ApiOperation(value = "查询该菜单模块下的按钮页签集合", notes = "查询该菜单模块下的按钮页签集合")
    public Response getButton(String resourceId) {
        return resourceService.getButton(resourceId);
    }

    /**
     * 保存资源信息
     */
    @PostMapping("/save/info")
    @ApiOperation(value = "保存资源信息", notes = "保存资源信息")
    public Response saveInfo(@RequestBody ResourceDTO resourceDTO) {
        return resourceService.saveInfo(resourceDTO);
    }

    /**
     * 更新资源信息
     */
    @PostMapping("/update/info")
    @ApiOperation(value = "更新资源信息", notes = "更新资源信息")
    public Response updateInfo(@RequestBody ResourceDTO bean) {
        return resourceService.updateInfo(bean);
    }

    /**
     * 删除资源信息
     */
    @GetMapping("/delete/info")
    @ApiOperation(value = "删除资源信息", notes = "删除资源信息")
    public Response deleteInfo(String resourceId) {
        return resourceService.deleteInfo(resourceId);
    }

}
